package com.zzs.judge.callback;

import com.github.dockerjava.api.async.ResultCallbackTemplate;
import com.github.dockerjava.api.model.Statistics;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

/**
 * @author zzs
 * @date 2025/03/31
 */
@NoArgsConstructor
@Getter
@Setter
public class MemoryStatsCallback extends ResultCallbackTemplate<MemoryStatsCallback, Statistics> {
    private long maxUseMemory = 0L;

    @Override
    public void onNext(Statistics object) {
        if (object.getMemoryStats() != null) {
            Long useMemory = object.getMemoryStats().getUsage();
            if (useMemory != null && useMemory > maxUseMemory) {
                maxUseMemory = useMemory;
            }
        }
    }
}
